//
//  YXForumVideoView.m
//  CreditCard
//
//  Created by 杨旭 on 2018/1/26.
//  Copyright © 2018年 杨旭. All rights reserved.
//

#import "YXForumVideoView.h"
#import "CDPVideoPlayer.h"

@interface YXForumVideoView ()<CDPVideoPlayerDelegate>
@property(nonatomic,strong)CDPVideoPlayer *player;

@end

@implementation YXForumVideoView

-(instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        // 从xib中找到我们定义的view
        NSArray *viewArray = [[NSBundle mainBundle]loadNibNamed:@"YXForumVideoView" owner:self options:nil];
        self = viewArray[0];
        self.frame = frame;

//        self.player = [[CDPVideoPlayer alloc]initWithFrame:self.bounds url:@"http://mov.bn.netease.com/open-movie/nos/mp4/2016/05/12/SBLU90D75_sd.mp4" delegate:self haveOriginalUI:YES];
//        [self.picImageView addSubview:self.player];

    }
    return self;
    
}
- (IBAction)playBtnAction:(UIButton *)sender {
    sender.selected = !sender.selected;
    if (sender.selected == YES) {
        [sender setImage:[UIImage imageNamed:@""] forState:(UIControlStateNormal)];
        self.player = [[CDPVideoPlayer alloc]initWithFrame:self.bounds url:@"http://mov.bn.netease.com/open-movie/nos/mp4/2016/05/12/SBLU90D75_sd.mp4" delegate:self haveOriginalUI:YES];
        [self.picImageView addSubview:self.player];
        [self.player play];
    }else {
        [sender setImage:[UIImage imageNamed:@"播放"] forState:(UIControlStateNormal)];
        [self.player pause];
        [self.player close];
    }
    
}

@end
